﻿	using System;
	using System.Collections.Generic;
	using System.Linq;
	using System.Web;
	using System.Web.UI;
	using System.Web.UI.WebControls;
	using Facebook;
	
	
	namespace Test1
	{
	    public partial class Facebook : System.Web.UI.Page
	    {
            MyFB fb = new MyFB();
            String redirect_uri = "http://localhost:1312/Facebook.aspx";

	        protected void Page_Load(object sender, EventArgs e)
	        {

                string appId = "106732246076055";
                string apiKey = "93480d7507dc3e43e1cdf46383635197";
                string appSecret = "cad2e542580cb029262076b019003bff";
                string code = Request.QueryString["code"];

                if (code == "" || code == null)
                {
                    //request for authentication
                    Response.Redirect("https://graph.facebook.com/oauth/authorize?client_id=" + appId + "&redirect_uri=" + redirect_uri
                        + "&scope=offline_access");
                }

                fb.ApplicationSecret = appSecret;
                fb.ApplicationID = appId;
                string accessToken = fb.GetAccessToken(code, redirect_uri);
                System.Diagnostics.Debug.WriteLine("access token = " + accessToken);
                fb.AccessToken = accessToken;
	        }

            protected String get_personal_info()
            {
                return fb.GetPersonalInfo();
            }

            protected String get_friends()
            {
                return fb.GetFriends();
            }

            protected string get_name()
            {
                return fb.GetMyName();
            }
	    }
	}
	
